1. Field of the Invention
The invention relates to nonvolatile memories, and more particularly to flash memories.
2. Description of the Related Art
Nonvolatile memories are memories which keep data stored therein when powers supplied to the memories are switched off. A flash memory is a nonvolatile memory and is used as a memory card or a universal serial bus (USB) device to store data for a computer or a portable electronic device. Data can be electrically programmed into or removed from a flash memory. A flash memory is generally used as a data storage device for a personal digital assistant (PDA), a notebook, a digital music player, a digital camera, or a cell phone.
When a host wants to store data to a nonvolatile memory, a controller of the nonvolatile memory intervenes between the host and the nonvolatile memory to implement requests of the host. Referring to FIG. 1, a block diagram of a memory device 100 comprising a nonvolatile memory 104 is shown. In addition to the nonvolatile memory 104, the memory device 100 also comprises a controller 102. The controller 102 is coupled to a host, and manages data stored in the nonvolatile memory 104 according instructions from the host. In one embodiment, the controller 102 comprises a control unit 112, a data buffer 114, a host interface 116, and a storage interface 118. The host interface 116 is for data communication between the host and the controller 102. The storage interface 118 is for data communication between the controller 102 and the nonvolatile memory 104. The nonvolatile memory stores data according to instructions from the controller 102. In one embodiment, the nonvolatile memory 104 comprises a storage interface 126, a data register 124, and a memory cell array 122. The storage interface 126 is for data communications between the controller 102 and the nonvolatile memory 104. The memory cell array 122 is for data storage.
When the host requests the controller 102 to store data to the nonvolatile memory 104, the controller 102 performs write operations according to instructions from the host. Referring to FIG. 2, a flowchart of a method 200 for writing data to the nonvolatile memory 104 shown in FIG. 1 is shown. First, the controller 102 receives data to be written to the nonvolatile memory 104 from the host via the host interface 116. The data is then stored in the data buffer 114 (step 202). The control unit 112 then sends a write command to the nonvolatile memory 104 via the storage interface 118 (step 204). The control unit 112 then sends a write address to the nonvolatile memory 104 via the storage interface 118 (step 206). The control unit 112 then sends the data stored in the data buffer 114 to the nonvolatile memory 104 via the storage interface 118, and the nonvolatile memory 104 stores the data received from the controller 102 in the data register 124 (step 208).
The nonvolatile memory 104 then writes the data stored in the data register 124 to a memory space with the write address in the memory cell array 122 according to the write command (step 209). The control unit 112 then sends a status check command to the nonvolatile memory 104 via the storage interface 118 (step 210). If an error occurs when the nonvolatile memory 104 writes the data to the memory space, the nonvolatile memory 104 then reports the error to the controller 102. If the nonvolatile memory 104 reports a write error to the controller 102, the controller 102 repeats the steps 204˜210 until the nonvolatile memory 104 reports that there were no errors to the controller 102 has occurred (step 212). In other words, when the nonvolatile memory 104 reports a write error to the controller 102, the controller 102 must resend a write command (step 204), a new write address (step 206), and the data (step 208) to the nonvolatile memory 104, and the nonvolatile memory 104 will write the data to a memory space with the new write address in the memory cell array 122 (step 209). The write operation is completed if the nonvolatile memory 104 reports that there were no errors after the nonvolatile memory 104 received a status check command (step 210). A data write process is completed if the host does not send new data to the controller 102 (step 214).
After the conventional nonvolatile memory 104 writes the data stored in the data register 124 to the memory cell array 122, the data register 124 of the nonvolatile memory 104 cannot keep the data stored therein unchanged. The controller 102 therefore must keep the data stored in the data buffer 114 after the nonvolatile memory 104 writes the data stored in the data register 124 to the memory cell array 122. If a write error occurs during step 212, the controller 102 can then resend the data stored in the data buffer 114 to the data register 124 of the nonvolatile memory 104 to be rewritten to the memory cell array 122.
However, the conventional method 200 for writing data to the nonvolatile memory 104 has shortcomings. First, after the data stored in the data register 124 is written to the memory cell array 122, because the data buffer 114 of the controller 102 has to keep the data stored therein, the controller 102 therefore requires a data buffer 114 with large memory size. Thus, manufacturing cost is increased. In addition, when a write error occurs, the controller 102 resends a write command, a write address, and data to the nonvolatile memory 104. Resending of the write command, the write address, and the data causes delays in the data write process and degrades performances of the memory device 100. A method for managing writing errors for a nonvolatile memory is therefore required to reduce the memory size of the data buffer 114 and reduce the time delay of the data write process, thereby reducing manufacturing cost of the controller 102 and increasing system performance.